<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>问题反馈</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" href="../../../lib/layui-v2.5.5/css/layui.css" media="all">
		<link rel="stylesheet" href="../../../css/public.css" media="all">
	</head>
	<body>
		<!--表格开始-->
		<table class="layui-hide" id="roleTable" lay-filter="roleTable"></table>
		<script type="text/html" id="roleToolBar">
		    <a class="layui-btn layui-btn-sm" lay-event="add">添加</a>
		</script>
		<script type="text/html" id="roleTableBar">
			<a class="layui-btn layui-btn-xs layui-btn-warm data-count-delete" lay-event="update">修改</a>
		</script>
		
		<!--添加和修改的弹出层开始-->
		<div id="addOrUpdateDiv" style="display: none;padding: 0.3125rem">
			<form method="post" class="layui-form layui-form-pane" lay-filter="dataFrm" id="dataFrm">
			
				  <div class="layui-form-item">
						<label class="layui-form-label">宝贵建议</label>
						<div class="layui-input-block">
							<input type="hidden" name="id">
							<textarea placeholder="请输入您的建议"  name="suggest" class="layui-textarea"></textarea>
						</div>
				   </div>
				  <div class="layui-form-item">
						<div class="layui-input-block" style="text-align: center;">
							<a class="layui-btn " lay-submit=""  lay-filter="doSubmit"><label class="layui-icon layui-icon-release"></label>提交</a>
							<a class="layui-btn layui-btn-warm" onclick="javascript:$('#dataFrm')[0].reset()" lay-filter="data-search-btn"><label class="layui-icon layui-icon-refresh"></label>重置</a>
						
						</div>
				   </div>
			</form>
		</div>
		<!--添加和修改的弹出层结束-->
		
<script src="../../../lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<script src="../../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="../../../js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script src="../../../lib/jq-module/jquery.particleground.min.js" charset="utf-8"></script>
<script src="../../../lib/common/jquery.cookie.min.js" charset="utf-8"></script>
<script src="../../../lib/common/common.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table','laydate','layer'], function () {
        var form = layui.form;
        var table = layui.table;
		var laydate=layui.laydate;
		var layer=layui.layer;

      var tableIns=table.render({
            elem: '#roleTable',
            url: api+'feed/queryAllFeedback',
			toolbar:"#roleToolBar",
			cellMinWidth:true,
            cols: [[
                {type: "checkbox",  fixed: "left"},
                {field: 'id', title: 'ID', align: "center"},
                {field: 'createtime',  title: '反馈时间', align: "center"},
				{field: 'suggest',  title: '当次建议', align: "center"},
				{field: 'isrenting',  title: '是否处理', align: "center",width: 120,templet: function (d) {
                        return d.isrenting == '1' ? '<font color=blue>已处理</font>' : '<font color=red>未处理</font>';
                    }
					},
                {field: 'username',  title: '姓名', align: "center"},
				{field: 'title',  title: '反馈部门', align: "center"},
				{field: 'ordernum',  title: '排序码', align: "center"},
                {title: '操作', templet: '#roleTableBar', fixed: "right", align: "center"}
            ]],
            page: true
        });
	//监听行数据的事件
	table.on('tool(roleTable)', function (obj) {
	    var data = obj.data;
	  
	    if(obj.event === 'update'){
			openUpdateRole(data);
	    }
	});

		//监听表头的事件
		table.on('toolbar(roleTable)', function(obj){
		  var checkStatus = table.checkStatus(obj.config.id);
		  switch(obj.event){
			case 'add':
				openAddRole();
			break;
		  };
		});
		
		//打开添加角色的弹层
		var mainIndex;
		var url;  //动态的url
		function openAddRole(){
			mainIndex=layer.open({
				type:1,
				title:'添加建议',
				content:$("#addOrUpdateDiv"),
				area:['800px','400px'],
				success:function(index){
					url=api+"feed/addFeedback";
					//重置表单
					$("#dataFrm")[0].reset();
				}
			});	
		}
	
		function openUpdateRole(data){
			mainIndex=layer.open({
				type:1,
				title:'修改当此意见',
				content:$("#addOrUpdateDiv"),
				area:['800px','400px'],
				success:function(index){
					url=api+"feed/updateFeedback";
					//装载数据表格
					form.val("dataFrm",data);
				}
			});	
		}
		//提交数据
		form.on("submit(doSubmit)",function(data){
			var params= $("#dataFrm").serialize();
			$.post(url,params, function(res){
				layer.msg(res.msg);
				if(res.code==200){
					tableIns.reload();
				}
				layer.close(mainIndex);
			})
			return false;
		});
    });
</script>
</body>
</html>
